ng911ok.lib.topology module#
Implements functionality related to topology.yml. Exposes
topology_config, which contains the data derived from topology.yml``.
Provides constructors for the following YAML tags (on yaml.SafeLoader):
!FieldRole(Scalar ->NG911Field) - Given a field’srole, returns the corresponding field object!DomainName(Scalar ->NG911Domain) - Given a domain’sname, returns the corresponding field object
- final class TopologyRule(dataset: str, member1: NG911FeatureClass, rule: str, member2: NG911FeatureClass | None = None)#
Bases:
object- classmethod as_df(members_as: Literal['OBJECT', 'ROLE', 'NAME'] = 'OBJECT', rule_as: Literal['DESCRIPTION', 'ETRT'] = 'DESCRIPTION') DataFrame#
Returns all registered topology rules as a
DataFramewith three columns:member1,rule, andmember2.The
member1andmember2columns will have the dtypeobjectif members_as isOBJECTor the dtypestring[python]if members_as isROLE(meaning theNG911FeatureClass.roleattribute) orNAME(meaning theNG911FeatureClass.nameattribute).The
rulecolumn will have the dtypestring[python].- Parameters:
members_as (Literal["OBJECT", "ROLE", "NAME"]) – How the member should be represented.
rule_as (Literal["DESCRIPTION", "ETRT"]) – How the rules should be represented.
- Return pd.DataFrame:
The registered topology rules as a
DataFrame.
- classmethod from_dict(dataset: str, data: _OneMemberTopologyRuleDict | _TwoMemberTopologyRuleDict) Self#
- add_rule_to_topology(topology_name: str, manager: EnvManager | None = None) Result#
Adds the rule to a topology using
arcpy.
- as_series(members_as: Literal['OBJECT', 'ROLE', 'NAME'] = 'OBJECT', rule_as: Literal['DESCRIPTION', 'ETRT'] = 'DESCRIPTION') Series#
- has_member(feature_class: NG911FeatureClass) bool#
Returns whether a given feature class is a member of the rule.
- _registered_rules: ClassVar[list[Self]] = [TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'discrepancyagency_boundary'>, rule='Must Not Overlap (Area)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'esb_ems_boundary'>, rule='Must Not Have Gaps (Area)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'esb_fire_boundary'>, rule='Must Not Have Gaps (Area)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'esb_law_boundary'>, rule='Must Not Have Gaps (Area)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'psap_boundary'>, rule='Must Not Have Gaps (Area)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'road_centerline'>, rule='Must Not Overlap (Line)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'road_centerline'>, rule='Must Not Have Dangles (Line)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'road_centerline'>, rule='Must Not Self-Overlap (Line)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'road_centerline'>, rule='Must Not Self-Intersect (Line)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'road_centerline'>, rule='Must Be Single Part (Line)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'address_point'>, rule='Must Be Properly Inside (Point-Area)', member2=<NG911FeatureClass 'discrepancyagency_boundary'>), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'road_centerline'>, rule='Must Be Inside (Line-Area)', member2=<NG911FeatureClass 'discrepancyagency_boundary'>), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'esb_ems_boundary'>, rule='Must Cover Each Other (Area-Area)', member2=<NG911FeatureClass 'discrepancyagency_boundary'>), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'esb_fire_boundary'>, rule='Must Cover Each Other (Area-Area)', member2=<NG911FeatureClass 'discrepancyagency_boundary'>), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'esb_law_boundary'>, rule='Must Cover Each Other (Area-Area)', member2=<NG911FeatureClass 'discrepancyagency_boundary'>), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'esz_boundary'>, rule='Must Cover Each Other (Area-Area)', member2=<NG911FeatureClass 'discrepancyagency_boundary'>), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'psap_boundary'>, rule='Must Cover Each Other (Area-Area)', member2=<NG911FeatureClass 'discrepancyagency_boundary'>)]#
- dataset: str#
- member1: NG911FeatureClass#
- member2: NG911FeatureClass | None#
- property members: tuple[NG911FeatureClass] | tuple[NG911FeatureClass, NG911FeatureClass]#
Returns a tuple of the member or members of the rule.
- rule: str#
- property rule_code: str#
Returns the
esriTopologyRuleTypecode for the rule.
- class _NG911TopologyConfig(exception_field: NG911Field, exception_domain: NG911Domain, required_dataset_topology_name: str, optional_dataset_topology_name: str, required_dataset_rules: FrozenList[TopologyRule], optional_dataset_rules: FrozenList[TopologyRule])#
Bases:
YAMLObject- yaml_loader#
alias of
SafeLoader
- classmethod from_yaml(loader: SafeLoader, node: Node)#
Convert a representation node to a Python object.
- add_members_to_topology(gdb: str, *, required_ds_topology: str | None = None, optional_ds_topology: str | None = None) tuple[int, int]#
Adds all missing members to the required and/or optional datasets’ topologies.
- Parameters:
gdb (str) – Path to the NG911 geodatabase
required_ds_topology (str) – Name of the topology in the required feature dataset
optional_ds_topology (str) – Name of the topology in the optional feature dataset
- Returns:
Number of feature classes added to the required and optional datasets’ topologies, respectively
- Return type:
tuple[int, int]
- enrich_error_df(error_df: DataFrame, members: Collection[DataFrame], fill_na_submit: bool | None = None) DataFrame#
Processes a topology error DataFrame (from the Export Topology Errors geoprocessing tool). Unless it is empty, the returned
pandas.DataFramewill have the following columns:Column Name
dtypeOriginObjectClassNamestringOriginObjectIDInt32DestinationObjectClassNamestringDestinationObjectIDInt32RuleTypestringRuleDescriptionstringSHAPEgeometryOriginObjectClassObjectobjectOriginObjectNGUIDstringOriginObjectSubmitbooleanOriginObjectExceptionsobjectDestinationObjectClassObjectobjectDestinationObjectNGUIDstringDestinationObjectSubmitbooleanDestinationObjectExceptionsobjectRuleObjectobjectIsExceptionboolean- Parameters:
error_df – Topology error DataFrame
members – All relevant member feature classes as DataFrames
fill_na_submit – Value to assume for invalid values of
SUBMIT; ifNone, a ValueError will be raised if any features involved in an error have an invalid or missing value for that attribute; default None
- Returns:
Copy of topology error DataFrame with additional columns
- get_rule(member1: NG911FeatureClass | NAType | None, rule_code: esriTopologyRuleType | str, member2: NG911FeatureClass | NAType | None = None) TopologyRule | None#
Searches through the known rules for a rule matching the arguments and returns it. Returns
Noneif no rule is found.- Parameters:
member1 (NG911FeatureClass | NAType | None) – Feature class representing the first member
rule_code (esriTopologyRuleType | str) – The string code (e.g., esriTRTLineNoDangles), the string description (e.g., “Must Not Have Dangles (Line)”), or the
esriTopologyRuleTypeinstance representing the rulemember2 (NG911FeatureClass | NAType | None) – Feature class representing the second member, or
None(orpandas.NA, which will be treated the same asNone) if not applicable; defaultNone
- Returns:
The rule matching the arguments, or
Noneif no such rule could be found- Return type:
TopologyRule | None
- _dangle_exc = frozenset({'esriTRTLineNoDangles'})#
- _inside_exc = frozenset({'esriTRTLineInsideArea', 'esriTRTPointProperlyInsideArea'})#
- address_point_allowed_values: ClassVar[frozenset[LiteralString]] = frozenset({'INSIDE_EXCEPTION', 'NO_EXCEPTION'})#
- exception_domain: NG911Domain#
- exception_field: NG911Field#
- exception_mapping: ClassVar[FrozenDict[LiteralString, frozenset[str]]] = FrozenDict({'DANGLE_EXCEPTION': frozenset({'esriTRTLineNoDangles'}), 'INSIDE_EXCEPTION': frozenset({'esriTRTPointProperlyInsideArea', 'esriTRTLineInsideArea'}), 'BOTH_EXCEPTION': frozenset({'esriTRTPointProperlyInsideArea', 'esriTRTLineInsideArea', 'esriTRTLineNoDangles'}), 'NO_EXCEPTION': frozenset()})#
- property optional_dataset_members: frozenset[NG911FeatureClass]#
Returns a
frozensetwith allNG911FeatureClassobjects that are involved inself.optional_dataset_rules.
- optional_dataset_rules: FrozenList[TopologyRule]#
- optional_dataset_topology_name: str#
- property required_dataset_members: frozenset[NG911FeatureClass]#
Returns a
frozensetwith allNG911FeatureClassobjects that are involved inself.required_dataset_rules.
- required_dataset_rules: FrozenList[TopologyRule]#
- required_dataset_topology_name: str#
- yaml_tag = '!TopologyConfig'#
- class _TopologyConfigDict#
Bases:
TypedDict- exception_domain: NG911Domain#
- exception_field: NG911Field#
- optional_dataset_rules: NotRequired[list[_OneMemberTopologyRuleDict | _TwoMemberTopologyRuleDict]]#
- optional_dataset_topology_name: str#
- required_dataset_rules: list[_OneMemberTopologyRuleDict | _TwoMemberTopologyRuleDict]#
- required_dataset_topology_name: str#
- _construct_domain_from_name(loader: SafeLoader, node: Node) NG911Domain#
- _construct_field_from_role(loader: SafeLoader, node: Node) NG911Field#
- topology_config: _NG911TopologyConfig = _NG911TopologyConfig(exception_field=NG911Field(role='topoexcept', name='TopoExcept', type='String', priority='M', length=20, domain=<NG911Domain 'TOPOEXCEPT' [4 Entries]>, fill_value='NO_EXCEPTION'), exception_domain=<NG911Domain 'TOPOEXCEPT' [4 Entries]>, required_dataset_topology_name='NG911_Topology', optional_dataset_topology_name='OptionalLayers_Topology', required_dataset_rules=FrozenList((TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'discrepancyagency_boundary'>, rule='Must Not Overlap (Area)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'esb_ems_boundary'>, rule='Must Not Have Gaps (Area)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'esb_fire_boundary'>, rule='Must Not Have Gaps (Area)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'esb_law_boundary'>, rule='Must Not Have Gaps (Area)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'psap_boundary'>, rule='Must Not Have Gaps (Area)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'road_centerline'>, rule='Must Not Overlap (Line)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'road_centerline'>, rule='Must Not Have Dangles (Line)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'road_centerline'>, rule='Must Not Self-Overlap (Line)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'road_centerline'>, rule='Must Not Self-Intersect (Line)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'road_centerline'>, rule='Must Be Single Part (Line)', member2=None), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'address_point'>, rule='Must Be Properly Inside (Point-Area)', member2=<NG911FeatureClass 'discrepancyagency_boundary'>), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'road_centerline'>, rule='Must Be Inside (Line-Area)', member2=<NG911FeatureClass 'discrepancyagency_boundary'>), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'esb_ems_boundary'>, rule='Must Cover Each Other (Area-Area)', member2=<NG911FeatureClass 'discrepancyagency_boundary'>), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'esb_fire_boundary'>, rule='Must Cover Each Other (Area-Area)', member2=<NG911FeatureClass 'discrepancyagency_boundary'>), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'esb_law_boundary'>, rule='Must Cover Each Other (Area-Area)', member2=<NG911FeatureClass 'discrepancyagency_boundary'>), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'esz_boundary'>, rule='Must Cover Each Other (Area-Area)', member2=<NG911FeatureClass 'discrepancyagency_boundary'>), TopologyRule(dataset='NG911', member1=<NG911FeatureClass 'psap_boundary'>, rule='Must Cover Each Other (Area-Area)', member2=<NG911FeatureClass 'discrepancyagency_boundary'>))), optional_dataset_rules=FrozenList(()))#
The single instance of
_NG911TopologyConfigthat contains the topology rules specified intopology.yml.